package edu.xhu.homepage.controller;

import edu.xhu.homepage.service.BiliMainChannelService;
import edu.xhu.homepage.service.BiliVideoService;
import edu.xhu.homepage.service.BiliChannelService;
import edu.xhu.homepage.service.HotVideoService;
import edu.xhu.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.*;

@Api(value = "bilibili主页", tags = "bilibili主页")
@CrossOrigin
@RestController
@RequiredArgsConstructor
@RequestMapping("/homepage")
public class HomePageController {

    private final BiliVideoService biliVideoService;

    private final HotVideoService hotVideoService;

    private final BiliMainChannelService mainChannelService;

    private final BiliChannelService channelsService;

    @GetMapping("/v1/recommendation")
    @ApiOperation("主页视频推荐")
    public ResponseResult<?> videoRecommendation() {
        return biliVideoService.videoRecommendation();
    }

    @GetMapping("/v1/advertisement")
    @ApiOperation("主页轮播图广告")
    public ResponseResult<?> carrouselAdvertisementMap() {
        return biliVideoService.carrouselAdvertisementMap();
    }

    @GetMapping("/v1/hotvideos")
    @ApiOperation("查询热点视频")
    public ResponseResult<?> queryHotVideos() {
        return hotVideoService.getHotVideos();
    }

    @GetMapping("/channelInfo")
    @ApiOperation("查询分区信息")
    public ResponseResult<?> queryChannelInfo() {
        return mainChannelService.queryChannelInfo();
    }

    @PostMapping("/videoDetail")
    @ApiOperation("查询视频详情")
    public ResponseResult<?> videoDetail(@Param("videoId") Long videoId) {
        return biliVideoService.videoDetail(videoId);
    }

    @GetMapping("/channels")
    @ApiOperation("查询主页主分区列表")
    public ResponseResult<?> queryMainChannels() {
        return channelsService.queryMainChannels();
    }
}